/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SMeterInputConverter.java
 * Created：		2016年8月30日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.device.inspect.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.rest.common.AOperateInfoConverter;
import com.thor.palmmall.rest.common.ASourceBillConverter;
import com.thor.palmmall.rest.device.inspect.ADeviceInspect;
import com.thor.palmmall.spi.device.SDeviceInspect;

/**
 * @author wolv
 *
 */
public class ADeviceInspectConverter implements Converter<SDeviceInspect, ADeviceInspect> {

  public static ADeviceInspectConverter getInstance() {
    if (instance == null)
      instance = new ADeviceInspectConverter();
    return instance;
  }

  private static ADeviceInspectConverter instance;

  private ADeviceInspectConverter() {
  }

  @Override
  public ADeviceInspect convert(SDeviceInspect source) {
    if (source == null)
      return null;

    ADeviceInspect target = new ADeviceInspect();

    target.setUuid(source.getUuid());
    target.setVersion(source.getVersion());
    target.setVersionTime(source.getVersionTime());
    target.setCreateInfo(AOperateInfoConverter.getInstance().convert(source.getCreateInfo()));
    target
        .setLastModifyInfo(AOperateInfoConverter.getInstance().convert(source.getLastModifyInfo()));
    target.setPermGroupId(source.getPermGroupId());
    target.setPermGroupTitle(source.getPermGroupTitle());
    target.setBillNumber(source.getBillNumber());
    target.setBizState(source.getBizState());
    target.setBpmInstance(source.getBpmInstance());
    target.setBpmMessage(source.getBpmMessage());
    target.setBpmOutgoingState(source.getBpmOutgoingState());
    target.setBpmState(source.getBpmState());
    target.setAbortMsg(source.getAbortMsg());
    target.setStore(UCN.newInstance(source.getStore()));
    target.setInspectTopic(source.getInspectTopic());
    target.setCategory(UCN.newInstance(source.getCategory()));
    target.setInspector(UCN.newInstance(source.getInspector()));
    target.setBeginTime(source.getBeginTime());
    target.setEndTime(source.getEndTime());
    target.setOverTime(source.getOverTime());
    target.setAbortTime(source.getAbortTime());
    target.setRemark(source.getRemark());
    target.setSettleNo(source.getSettleNo());
    target.setSourceUuid(source.getSourceUuid());
    target.setSourceBillNumber(source.getSourceBillNumber());
    target.setDeviceRepair(ASourceBillConverter.getInstance().convert(source.getDeviceRepair()));
    target.setDetails(
        ConverterUtil.convert(source.getDetails(), ADeviceInspectDetailConverter.getInstance()));

    return target;
  }

}
